<template>
    <view class="container">
        <view class="title">{{ title }}</view>
        <view class="time">更新日期：{{ time }}</view>
        <u-parse :content="content"></u-parse>
    </view>
</template>

<script setup>
import { onLoad, onReady } from "@dcloudio/uni-app"
import { nextTick, ref } from "vue";
import {getProtocolDesc} from "@/api/cms";

const content = ref('')
const title = ref('')
const time = ref('')

onLoad(({ status }) => {
    // 1用户 2隐私
    handleGetAgreement(status)

    // nextTick(() => {
    // 	uni.setNavigationBarTitle({
    // 		title: status == 1 ? '用户协议' : '隐私政策'
    // 	})
    // })
})

const handleGetAgreement = async (type) => {
    let protocolType = ''
    console.log('type',type)
    switch (type) {
        case '1':
            // 用户协议
            protocolType = 'user_protocol'
            break;
        case '2':
            // 隐私协议
            protocolType = 'privacy_protocol'
            break;
        case '3':
            // 平台协议
            protocolType = 'platform_protocol'
            break;
        case '4':
            // 会员服务协议
            protocolType = 'membership_service_protocol'
            break;
        case '5':
            // 会员充值协议
            protocolType = 'member_recharge_protocol'
            break;
        case '6':
            // 邀请活动协议
            protocolType = 'invitation_activity_desc'
            break;
    }

    const {code, data, message} = await getProtocolDesc(protocolType)
    title.value = data.title
    content.value = data.value
    time.value = data.updated_at
}
</script>

<style lang="scss" scoped>
.container {
    padding: 34rpx;
    .title {
        margin-top: 30rpx;
        font-size: 40rpx;
        font-weight: bold;
        color: #000000;
    }
    .time {
        margin-top: 20rpx;
        font-size: 30rpx;
        color: #AAAAAA;
        margin-bottom: 45rpx;
    }
}
</style>
